﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CCalc__
{
    public class mathOps
    {            
            //This file will contain all of the mathmatical operators that were once condensed into one file.
        public void Addition()
        {
            //Do Addition here
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Addition]{|+|====|+|}\n\n");//Give the user a facny boiler plate to tell where they are
            Console.Write("First number: "); //Prompt for the first number
            string add1In = Console.ReadLine(); //Gathers the first number
            double add1; //Creates a storage variable
            double.TryParse(add1In, out add1); //Converts the string to a number (double) which is then stored in the storage variable
            //This is really just the same process as above.
            Console.Write("Second number: ");
            string add2In = Console.ReadLine();
            double add2;
            double.TryParse(add2In, out add2);
            //Here is where things change
            double answer = add1 + add2; //Creates another variable with a solution to the two numbers the user wanted to calculate
            Console.WriteLine("\nThe answer to: " + add1 + " + " + add2 + " = " + answer + "\n"); //Final output of the solution.
            /*
                * INREF: GOBACK
                * This part right here is a simple loopback script designed to ask the user if they want to do more with the calculator.
                * Due to console apps exiting as soon as they are done running I made this up for two reasons
                * 1.) So the user can use the app again with out needing to restart it him or herself.
                * 2.) So the user actually gets to see the output of thier calculations.
                */
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }
        public void Subtraction()
        {
            //Do Subtraction here
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Subtraction]{|+|====|+|}\n\n");
            Console.Write("First number: ");
            string sub1In = Console.ReadLine();
            double sub1;
            double.TryParse(sub1In, out sub1);
            Console.Write("Second number: ");
            string sub2In = Console.ReadLine();
            double sub2;
            double.TryParse(sub2In, out sub2);
            double answer = sub1 - sub2;
            Console.WriteLine("\nThe answer to: " + sub1 + " - " + sub2 + " = " + answer + "\n");
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }
        public void Multiplication()
        {
            //Do Multiplication here
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Multiplication]{|+|====|+|}\n\n");
            Console.Write("First number: ");
            string mult1In = Console.ReadLine();
            double mult1;
            double.TryParse(mult1In, out mult1);
            Console.Write("Second number: ");
            string mult2In = Console.ReadLine();
            double mult2;
            double.TryParse(mult2In, out mult2);
            double answer = mult1 * mult2;
            Console.WriteLine("\nThe answer to: " + mult1 + " x " + mult2 + " = " + answer + "\n");
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }
        public void Division()
        {
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Division]{|+|====|+|}\n\n");
            Console.Write("First number: ");
            string div1In = Console.ReadLine();
            double div1;
            double.TryParse(div1In, out div1);
            Console.Write("Second number: ");
            string div2In = Console.ReadLine();
            double div2;
            double.TryParse(div2In, out div2);
            double answer = div1 / div2;
            Console.WriteLine("\nThe answer to: " + div1 + " / " + div2 + " = " + answer + "\n");
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }

        public void SquareRoot()
        {
            //Square Roots here
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Square Root]{|+|====|+|}\n\n");
            Console.Write("Number to root: ");
            string rootIn = Console.ReadLine();
            double root;
            double.TryParse(rootIn, out root);
            double rootOut = Math.Sqrt(root); //Converts the parsed double into its sqare root
            Console.WriteLine("The square root is: " + rootOut + "\n"); //Displays the Square root of the entered number
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }
        public void SphericalAV()
        {
            //Calcuations for area / volume of a sphere here
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Area of a Sphere]{|+|====|+|}\n\n");
            const double pi = 3.14159; //Create a constant double for pi can also be handeled by using Math.pi
            Console.Write("Please enter a number to calculate: ");
            string radInput = Console.ReadLine();
            double rad;
            double.TryParse(radInput, out rad);
            double area = Math.Pow(rad, 2) * 4 * pi; // Calculation of the area of the sphere
            double volume = 4 / 3 * pi * Math.Pow(rad, 3); // Calculation of the volume of the sphere
            Console.WriteLine("\nA sphere with a radius of: " + rad + " inches" + "\nHas an area of: " + area + "\nAnd a volume of: " + volume);
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }
        public void TimesTable()
        {
            Console.Clear();
            Console.WriteLine("{|+|====|+|}[CCalc++ Ver: 0.1 -- Times Tables]{|+|====|+|}\n\n");
            Console.Write("Please enter an integer to generate a" + " multiplication table for: ");

            int num = int.Parse(Console.ReadLine());
            Console.WriteLine("\n");
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Console.Write((num + i) * (num + j) + "\t");
                }
                Console.Write("\n");
            }
            Console.WriteLine("\nWould you like to do another calcuation? \n1.) Yes \n2.) No\n"); // Created a menu for the user to pick from
            Console.Write("Please pick an option: "); // Prompts for user input
            string exitOtpIn = Console.ReadLine(); //Gathers user input
            double exitOptOut; //Storage variable for later
            double.TryParse(exitOtpIn, out exitOptOut); //Conversion of the string to a double stored in the variable from before
            if (exitOptOut == 1) //Checks for input and applies the conditions that follow
            {
                Console.WriteLine("\nStarting over......\n"); //Some info for the user
                System.Threading.Thread.Sleep(500); //Causes the system to wait for 500 miliseconds
                Program menu = new Program();
                menu.menuMain(); //Goes back to the main menu
            }
            if (exitOptOut == 2) //Checks for option 2
            {
                Console.WriteLine("\nExiting Calculator.... Thanks for using!"); //Displays a thank you message
                System.Threading.Thread.Sleep(500); //Waits for 500ms before exiting the calculator
            }
        }

        }

   }
